package com.logansoft.zhxypkoa.domain.sys;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.springframework.context.annotation.Scope;
import org.springframework.data.rest.core.annotation.RestResource;

import com.logansoft.zhxypkoa.domain.Actions;
import com.logansoft.zhxypkoa.domain.Base;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 权限模型
 * 
 * @author zhuyj
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "s_sys_premission")
@Scope(value = "prototype")
public class Premission extends Base {

  private static final long serialVersionUID = 1L;
  /**
   * 视图
   */
  /*@OneToOne(targetEntity = Dataset.class)
  @JoinColumn(name = "VIEW_ID")
//  @RestResource(path = "view", rel = "view")
  private Dataset view;*/
  /**
   * 资源
   */
  @ManyToOne(targetEntity = Resource.class, fetch = FetchType.LAZY)
  @JoinColumn(name = "RESOURCE_ID")
  private Resource resource;
  /**
   * 行为
   */
  @Column(name = "ACTION")
  @Enumerated(EnumType.ORDINAL)
  private Actions action;
  /**
   * 包含的角色
   */
  @ManyToMany(mappedBy = "premissions", fetch = FetchType.LAZY)
  private List<Role> roles; 
  
  public Premission() {}
}
